﻿namespace Games.Klotski
{
    class Piece
    {
        /// <summary>
        /// 游戏移动的方块对象
        /// </summary>
        /// <param name="bkData">方块信息</param>
        /// <param name="id">方块的ID</param>
        public Piece(string bkData, int id)
        {
            X = bkData[1] - 48;
            Y = bkData[2] - 48;
            H = 1;
            W = 1;
            this.Id = id;
            var type = bkData[0];
            if(type == '0')
            {
                W = 2;
            }
            else if(type == '1')
            {
                W = 3;
            }
            else if(type == '2')
            {
                H = 2;
            }
            else if(type == '3')
            {
                H = 3;
            }
            IsHorizontal = this.H == 1;
        }

        public bool IsHorizontal { get; }
        /// <summary>
        /// 方块的ID
        /// </summary>
        public int Id { get; }

        /// <summary>
        /// 宽度
        /// </summary>
        public int W { get; }

        /// <summary>
        /// 高度
        /// </summary>
        public int H { get; }

        /// <summary>
        /// 方块相对游戏区域左上角的横坐标
        /// </summary>
        public int X { get; internal set; }

        /// <summary>
        /// 方块相对游戏区域左上角的纵坐标
        /// </summary>
        public int Y { get; internal set; }
    }
}
